package com.itheima.app.manager.omsManager;

import cn.hutool.core.convert.Convert;
import com.itheima.commons.PageBean;
import com.itheima.commons.R;
import com.itheima.domain.db.oms.OmsOrderReturnReason;
import com.itheima.service.omsService.OrderReturnReasonService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * 退货原因
 */
@Component
public class OmsOrderReturnReasonManager {
    @DubboReference
    OrderReturnReasonService orderReturnReasonService;

    /**
     * 分页查询退货原因
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    public R pageReturnReason(Integer pageNum, Integer pageSize) {
        PageBean<OmsOrderReturnReason> pageBean = orderReturnReasonService.pageReturnReason(pageNum, pageSize);
        return R.ok(pageBean);
    }

    /**
     * 添加收货原因
     *
     * @param omsOrderReturnReason
     */
    public void addReturnReason(OmsOrderReturnReason omsOrderReturnReason) {
        orderReturnReasonService.addReturnReason(omsOrderReturnReason);
    }

    /**
     * 批量删除退货原因
     *
     * @param ids
     */
    public void deleteReturnReason(Integer[] ids) {
        orderReturnReasonService.deleteReturnReason(ids);
    }

    /**
     * 修改退货原因启用状态
     */
    public void updateStatus(Integer ids, Integer status) {
        orderReturnReasonService.updateStatus(ids, status);
    }

    /**
     * 获取单个退货原因详情信息
     *
     * @param id
     * @return
     */
    public R getInfoById(Integer id) {
        OmsOrderReturnReason omsOrderReturnReason = orderReturnReasonService.getInfoById(id);
        return R.ok(omsOrderReturnReason);
    }

    /**
     * 修改退货原因
     *
     * @param id
     * @param omsOrderReturnReason
     */
    public void updateInfo(Integer id, OmsOrderReturnReason omsOrderReturnReason) {
        if (omsOrderReturnReason.getId() == null) {
            omsOrderReturnReason.setId(Convert.toLong(id));
        }
        orderReturnReasonService.updateInfo(omsOrderReturnReason);
    }
}
